package org.vm.cmbcdirect.component.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.vm.cmbcdirect.utils.MessageUtil;
import org.vm.cmbcdirect.utils.SaveUploadUtil;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.List;

/**
 * Created by mv on 2016/3/24.
 */
@Controller
public class FaceController {

    @RequestMapping(value="/faceUpload",method= RequestMethod.GET)
    public String upload(){
        return "face/uploadImg";
    }

    @RequestMapping(value="/faceUpload", method= RequestMethod.POST)
    public String uploadByImg(HttpServletRequest request, Model model){

        List<File> files = (new SaveUploadUtil()).saveUploadUtil(request);
        if (files == null) {
            model.addAttribute("msg", MessageUtil.FACE_FOR_FAILURE);
            return "error/error";
        }




        return "face/uploadImg";
    }
}
